<!--  -->
<template>
  <div class>
    <section class="app-main">
      <div class="miaosha-box">
        <div class="datalist" style="margin-top:20px;">
          <div class="datalist-box">
            <i class="el-icon-document"></i>&nbsp;&nbsp;
            <span>数据列表</span>
            <el-button class="addactivity" style="float: right; " size="mini" @click="addAct">添加</el-button>
          </div>
        </div>
        <div class="table-container">
          <div class="datalist-content">
            <table class="tablee" cellspacing="0" cellpadding="0">
              <tr class="hang">
                <td style="width:100px">编号</td>
                <td style="width:300px">秒杀时间段名称</td>
                <td style="width:300px">每日开始时间</td>
                <td style="width:300px">每日结束时间</td>
                <td style="width:120px">启用</td>
                <td style="width:180px; border-right: 1px solid #ececec;">操作</td>
              </tr>
              <!-- 遍历数据 -->
              <tr class="hanglist" v-for="(item,index) in datalist" :key="item.id">
                <td style="width:100px">{{item.id}}</td>
                <td style="width:120px">{{item.timeSP}}</td>
                <td style="width:120px">{{item.StarTime}}</td>
                <td style="width:120px">{{item.AsOf}}</td>
                <td style="width:240px">
                  <el-switch v-model="item.kaiguan"></el-switch>
                </td>
                <td style="width:180px; border-right: 1px solid #ececec;" class="operation">
                  <el-button type="text" @click="editsuu">编辑</el-button>
                  <el-button type="text" @click="delShops(index)">删除</el-button>
                </td>
              </tr>
            </table>
          </div>
        </div>
      </div>


      <!-- 添加功能显示 -->
       <el-dialog title="添加活动" :visible.sync="edits">
        <el-form :model="form">
          <el-form-item label="活动名称：" label-width="120px">
            <el-input v-model="form.name" autocomplete="off" style="width:220px"></el-input>
          </el-form-item>
        </el-form>
        <div class="block" style="margin:20px 0 0 38px;">
          <span class="demonstration" style="margin-right:12px;">开始时间：</span>
          <el-date-picker
            v-model="actTime"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            label-width="320px"
          ></el-date-picker>
        </div>
        <el-form :model="form">
          <el-form-item label="是否启用：" label-width="120px">
            <el-radio-group v-model="form.resource">
              <el-radio :label="1">启用</el-radio>
              <el-radio :label="0">不启用</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="edits = false">取 消</el-button>
          <el-button type="primary" @click="edits = false">确 定</el-button>
        </div>
      </el-dialog>
    </section>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';

export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      input: "",
      // kaiguan: true,
      currentPage4: 4,
      value: "",
      datalist: [
        {
          id: 1,
          timeSP: "10:00",
          StarTime: "2018-12-11",
          AsOf: "2019-1-1",
          kaiguan: false,
        },
        {
          id: 2,
          timeSP: "12:00",
          StarTime: "2018-12-11",
          AsOf: "2019-1-1",
          kaiguan: false,
        },
        {
          id: 3,
          timeSP: "08:00",
          StarTime: "2018-12-11",
          AsOf: "2019-1-1",
          kaiguan: false,
        },
      ],
      edits: false,
      form: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
        shortcuts: [
          {
            text: "今天",
            onClick(picker) {
              picker.$emit("pick", new Date());
            },
          },
          {
            text: "昨天",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24);
              picker.$emit("pick", date);
            },
          },
          {
            text: "一周前",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", date);
            },
          },
        ],
      },
      actTime: "",
      // formLabelWidth: "120px",
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  created() {
    // this.getMiaoshaList()
  },
  methods: {
    async getMiaoshaList() {
      // const res = await this.$http.get()
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    setShops: function (index) {
      console.log("这里是设置商品", index);
    },
    editsuu: function (index) {
      console.log("这里是编辑", index);
      this.edits= true;
    },
    delShops: function (index) {
      console.log("这里是删除", index);
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
          this.datalist.splice(index, 1);
          console.log(this.$root);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    // 添加活动
    addAct: function () {
      console.log("这里是添加活动");
      this.edits=true;
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style scoped>
.app-main {
  min-height: 100%;
}
.miaosha-box {
  padding: 20px;
}
.app-main .miaosha-box .search-Box,
.datalist {
  border: 1px solid #ebeef5;
  background-color: #fff;
  color: #303133;
  border-radius: 4px;
}
.app-main .miaosha-box .search-Box .search-box,
.datalist-box {
  padding: 20px;
}
.app-main .miaosha-box .miaosha-input {
  /* width: 380px; */
  height: 32px;
  display: flex;
  align-items: center;
  font-size: 12px;
  margin-top: 30px;
}
.app-main .miaosha-box .miaosha-input span {
  /* width: 130px; */
  margin-left: 60px;
  font-size: 16px;
}
.addactivity span {
  width: 82px;
  height: 12px;
  line-height: 12px;
  font-size: 12px;
}
.datalist-content {
  /* width: 1127px; */
  min-height: 48px;
  margin-top: 20px;
}
.hang {
  height: 48px;
}

.tablee > tr > td {
  border: 1px solid #ececec;
  text-align: center;
  line-height: 48px;
  border-right: none;
}
.table-container .tablee .confirm {
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-top: 14px;
  /* outline: none;
    border: none; */
}
.operation {
  font-size: 13px;
}
.operation > button {
  border: none;
  outline: none;
  margin: 0 5px;
  background: #fff;
  color: #66b1ff;
}
</style>